<?php
class FundInfoVo extends SzAbstractMySqlVo
{

    private $userId;
    private $fundId;
    private $status;
    private $isComplete;
    private $receivedSituation;
    private $createTime;
    private $updateTime;
    private $endTime;

    /**
     * Initialize FundInfoVo.
     *
     * @param $userId
     * @param $fundId
     * @param $status
     * @param $isComplete
     * @param $receivedSituation
     * @param $createTime
     * @param $updateTime
     * @param $endTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return FundInfoVo
     */
    public function __construct($userId, $fundId, $status, $isComplete, $receivedSituation, $createTime, $updateTime, $endTime, $isInsert = false) {
        $this->userId = $userId;
        $this->fundId = $fundId;
        $this->status = $status;
        $this->isComplete = $isComplete;
        $this->receivedSituation = json_decode($receivedSituation, true);
        $this->createTime = $createTime;
        $this->updateTime = $updateTime;
        $this->endTime = $endTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'FundInfoVo';
        $this->ormName = 'FundInfo';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'fundId' => $this->getFundId(),
            'status' => $this->getStatus(),
            'isComplete' => $this->getIsComplete(),
            'receivedSituation' => ($needEncode) ? $this->getReceivedSituation() : $this->getRawReceivedSituation(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'fundId' => $this->getFundId(),
            'status' => $this->getStatus(),
            'isComplete' => $this->getIsComplete(),
            'receivedSituation' => ($needEncode) ? $this->getReceivedSituation() : $this->getRawReceivedSituation(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getFundId(),
            $this->getStatus(),
            $this->getIsComplete(),
            $this->getReceivedSituation(),
            $this->getCreateTime(),
            $this->getUpdateTime(),
            $this->getEndTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getFundId()
    {
        return $this->fundId;
    }

    public function setFundId($val)
    {
        $this->saveColumnStatus(1, $this->fundId);
        $this->fundId = $val;
    }

    public function getStatus()
    {
        return $this->status;
    }

    public function setStatus($val)
    {
        $this->saveColumnStatus(2, $this->status);
        $this->status = $val;
    }

    public function getIsComplete()
    {
        return $this->isComplete;
    }

    public function setIsComplete($val)
    {
        $this->saveColumnStatus(3, $this->isComplete);
        $this->isComplete = $val;
    }

    public function getReceivedSituation()
    {
        return json_encode($this->receivedSituation);
    }

    public function getRawReceivedSituation()
    {
        return $this->receivedSituation;
    }

    public function setReceivedSituation($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[FundInfoVo] The length of column receivedSituation exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('FundInfoVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[FundInfoVo] The length of column receivedSituation exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(4, $this->receivedSituation);
        $this->receivedSituation = $val;
    }

    public function getCreateTime()
    {
        return $this->createTime;
    }

    public function setCreateTime($val)
    {
        $this->saveColumnStatus(5, $this->createTime);
        $this->createTime = $val;
    }

    public function getUpdateTime()
    {
        return $this->updateTime;
    }

    public function setUpdateTime($val)
    {
        $this->saveColumnStatus(6, $this->updateTime);
        $this->updateTime = $val;
    }

    public function getEndTime()
    {
        return $this->endTime;
    }

    public function setEndTime($val)
    {
        $this->saveColumnStatus(7, $this->endTime);
        $this->endTime = $val;
    }

}